meanMatrixPlot <-function(inputMatrix,title="",xVec=NULL,xdesc="",ydesc="",summDesc=" ",directory="./",width=1024,height=1024){

if(is.null(xVec )){
	xVec <-1:ncol(inputMatrix)
}
if(length(xVec) !=ncol(inputMatrix) ){
	stop("length of xVac and number of columns of input matrix are not equal")
}
if(is.null(rownames(inputMatrix)) ){
	stop(" no rownames of inputMatrix ")
}
#directory <- paste(directory,chartr(" ","_",date()),"/",sep="")
directory <- paste(directory,"/",sep="")
#directory <- normalizePath(directory)
dir.create(directory)
colors <-rainbow(nrow(inputMatrix))
linetype <-1:nrow(inputMatrix)
#create separated files
for(row in 1:nrow(inputMatrix)){
	fname <-paste(directory,chartr("\n","_",title),row,".png",sep="")
	png(filename=fname, height=width, width=height,bg="white")
	plot(xVec,inputMatrix[row,],type="b",ann=FALSE,col=colors[row])
	title(paste(title,"\n",rownames(inputMatrix)[row],sep=""),xlab=xdesc,ylab=ydesc)
	grid()
	dev.off()
}
#create summary file
fname <-paste(directory,"summary",chartr("\n","_",title),".png",sep="")
ymin <- min(inputMatrix)
ymax <- max(inputMatrix)
xmin<- -2
xmax <-length(xVec)+1
png(filename=fname, height=width, width=height,bg="white")


plot(NULL,xlim=c(xmin,xmax),ylim=c(ymin,ymax),col.lab=rgb(0,0,0),ann=FALSE)

for(row in 1:nrow(inputMatrix)){
	lines(xVec,inputMatrix[row,],type="b",col=colors[row],lty=linetype[row])
}

legend(xmin, ymax, 1:nrow(inputMatrix), col=colors, lty=linetype, title="Algorithm")
print("DSC:: ");print(summDesc)
title(summDesc,xlab=xdesc,ylab=ydesc)
grid()
dev.off()



} 
